package com.zd.bms.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.zd.bms.bean.vo.req.WechatUserListReqVo;
import com.zd.bms.bean.vo.resp.WechatUserRespVo;
import com.zd.bms.service.IScenicSpotService;
import com.zd.bms.service.IUserInfoService;
import com.zd.common.dao.common.Page;

@Controller
@RequestMapping("wechat/user")
public class WechatUserController {
	@Autowired
	private IScenicSpotService scenicSpotService;
	
	@Autowired
	private IUserInfoService userInfoService;

	@RequestMapping("index")
	public ModelAndView index() throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("wechatUser/index");
		List<Map<String, Object>> scenicSpotList = scenicSpotService.getScenicSpotKeyValueList();
		mv.addObject("scenicSpotList", scenicSpotList);
		return mv;
	}

	@ResponseBody
	@RequestMapping("list")
	public  Map<String, Object> list(WechatUserListReqVo reqVo) throws Exception {
		Map<String, Object> resultMap = new HashMap<>();
		
		Page<WechatUserRespVo> wechatUserPage = userInfoService.pageWechatUser(reqVo);
		resultMap.put("data", wechatUserPage.getList());
		resultMap.put("draw", reqVo.getDraw());
		resultMap.put("recordsTotal", wechatUserPage.getList().size());
		resultMap.put("recordsFiltered", wechatUserPage.getTotalRow());
		resultMap.putAll(userInfoService.statisticalUser(reqVo));
		return resultMap;
	}
}
